﻿using System;

namespace CodeCounsel.SharePoint.RibbonDesigner.ViewModel
{
    public class ScalePickerViewModel
    {
        TabViewModel _owner;

        public int Maximum
        {
            get { return _owner.ScaleCount - 1; }
        }

        public int Minimum
        {
            get { return -1; }
        }

        public int Current
        {
            get { return _owner.ScaleIndex; }
            set
            {
                int toIndex = value;
                Action action = null;
                if (toIndex > Current)
                {
                    action = _owner.ScaleDown;
                }
                else
                {
                    action = _owner.ScaleUp;
                }
                int stepChange = Math.Abs(Current - toIndex);
                for (int i = 0; i < stepChange; i++)
                {
                    action();
                }
            }
        }

        public ScalePickerViewModel(TabViewModel owner)
        {
            _owner = owner;
        }
    }
}
